package com.chukun.protobuf;

/**
 * @author chukun
 * protobuf简单的操作
 */
public class StudentProtoBufRunner {

    public static void main(String[] args) throws  Exception{
        StudentInfo.Student student = StudentInfo.Student.newBuilder().setStuNo("001").setAge(12).setName("tom").setAddress("北京").build();
        //序列化操作
        byte[] student2Bytes = student.toByteArray();
        //反序列化操作
        StudentInfo.Student parseStudent = StudentInfo.Student.parseFrom(student2Bytes);
        System.out.println(parseStudent.getStuNo());
        System.out.println(parseStudent.getName());
        System.out.println(parseStudent.getAge());
        System.out.println(parseStudent.getAddress());
    }
}
